提款
# cogs/money.py
@commands.command()
async def withdraw(self, ctx, amount = None):
pass
await open_account(ctx.author)
- 再來,提款必須要有一個數字,如果沒有,就return回去
if amount == None:
await ctx.send("請輸入數字")
return
async def update_bank(user, change = 0, mode = "wallet"):
pass
users = await get_bank_data()
users[str(user.id)][mode] += change
with open("bank.json", "w") as f:
json.dump(users, f)
bal = [users[str(user.id)]["wallet"], users[str(user.id)]["bank"]]
return bal
bal = await update_bank(ctx.author)
amount = int(amount)
if amount > bal[1]:
await ctx.send("你沒這麼多錢拉幹")
return
if amount > 200:
await ctx.send("要小於200喔")
return
if amount< 0:
await ctx.send("北七喔,錢有負的喔")
return
await update_bank(ctx.author, amount)
await update_bank(ctx.author, -1*amount, "bank")
await ctx.send(f"你提款了 { amount } 塊錢!!!")
存款
# cogs/money.py
@commands.command()
async def deposit(ctx, amount = None):
pass
await update_bank(ctx.author, -1 * amount)
await update_bank(ctx.author, amount, "bank")
匯款
# cogs/money.py
@commands.command()
async def send(ctx, member:discord.Member, amount = None):
await open_account(ctx.author)
await open_account(member)
if amount == None:
await ctx.send("請輸入數字")
return
bal = await update_bank(ctx.author)
if amount == "all":
amount = bal[0]
amount = int(amount)
if amount > bal[1]:
await ctx.send("你沒這麼多錢拉幹")
return
if amount< 0:
await ctx.send("北七喔,錢有負的喔")
return
await update_bank(ctx.author, -1 * amount, "bank")
await update_bank(member, amount, "bank")
member = str(member)
member = member.split("#")[0]
await ctx.send(f"你給了{ member } { amount } 塊錢!!!")